package com.prs.crm.dao.receipt.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.context.AppContext;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.receipt.ReceiptMoudleDao;
import com.prs.crm.domain.receipt.ReceiptMoudle;

public class ReceiptMoudleDaoImpl extends BaseDaoImpl<ReceiptMoudle> implements ReceiptMoudleDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<ReceiptMoudle> getAllReceiptMoudle() {
		Criteria criteria=this.getSession().createCriteria(ReceiptMoudle.class);
		return criteria.list();
	}

	@Override
	public List<ReceiptMoudle> getReceiptMoudle() {
		Criteria criteria=this.getSession().createCriteria(ReceiptMoudle.class);		
		criteria.add(Restrictions.eq("moudleState","启用"));
		criteria.add(Restrictions.like("usePerson","%"+AppContext.getAccountContext().currentUser().getResume().getName()+"%"));
		return criteria.list();
	}

	@Override
	public List<ReceiptMoudle> getReceiptMoudleByName(String type) {
		Criteria criteria=this.getSession().createCriteria(ReceiptMoudle.class);		
		criteria.add(Restrictions.eq("name",type));
		return criteria.list();
	}
}
